<?php

/**
 * This is the model class for table "ndk_premi_non".
 *
 * The followings are the available columns in table 'ndk_premi_non':
 * @property integer $id
 * @property integer $createdby
 * @property string $createdtime
 * @property integer $updatedby
 * @property string $updatedtime
 * @property string $no_invoice
 * @property string $nama_client
 * @property integer $mst_client_id
 * @property string $due_date
 * @property double $nominal
 * @property string $keterangan
 * @property integer $mst_coa_id_debet
 * @property integer $mst_coa_id_kredit
 */
class NdkPremiNon extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'ndk_premi_non';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			//array('createdby, createdtime, updatedby, updatedtime', 'required'),
			array('createdby, updatedby, mst_client_id, mst_coa_id_debet, mst_coa_id_kredit', 'numerical', 'integerOnly'=>true),
			array('nominal', 'numerical'),
			array('no_invoice, nama_client', 'length', 'max'=>50),
			array('keterangan', 'length', 'max'=>100),
			array('due_date', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, createdby, createdtime, updatedby, updatedtime, no_invoice, nama_client, mst_client_id, due_date, nominal, keterangan, mst_coa_id_debet, mst_coa_id_kredit', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'createdby' => 'Createdby',
			'createdtime' => 'Createdtime',
			'updatedby' => 'Updatedby',
			'updatedtime' => 'Updatedtime',
			'no_invoice' => 'No Invoice',
			'nama_client' => 'Nama Client',
			'mst_client_id' => 'Mst Client',
			'due_date' => 'Due Date',
			'nominal' => 'Nominal',
			'keterangan' => 'Keterangan',
			'mst_coa_id_debet' => 'Mst Coa Id Debet',
			'mst_coa_id_kredit' => 'Mst Coa Id Kredit',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('createdby',$this->createdby);
		$criteria->compare('createdtime',$this->createdtime,true);
		$criteria->compare('updatedby',$this->updatedby);
		$criteria->compare('updatedtime',$this->updatedtime,true);
		$criteria->compare('no_invoice',$this->no_invoice,true);
		$criteria->compare('nama_client',$this->nama_client,true);
		$criteria->compare('mst_client_id',$this->mst_client_id);
		$criteria->compare('due_date',$this->due_date,true);
		$criteria->compare('nominal',$this->nominal);
		$criteria->compare('keterangan',$this->keterangan,true);
		$criteria->compare('mst_coa_id_debet',$this->mst_coa_id_debet);
		$criteria->compare('mst_coa_id_kredit',$this->mst_coa_id_kredit);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return NdkPremiNon the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
